import { CommonModule } from '@angular/common';
import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/http';
import { NgModule } from '@angular/core';
import { CoreRoutingModule } from "./core-routing.module";
import { MainComponent } from "./component/main/main.component";
import { PublicConfig } from "./service/config/config";
import { TabService } from "./service/tab/tab.service";
import { FormService } from "./service/tools/form.service";
import { RegisterService } from "./service/register/register.service";
import { LayerComponent } from "./component/layer/layer.component";
import { StoreModule } from '@ngrx/store';
import { MsgTable } from "./service/reduxstore/msg/msg.redux";
import { PropupMsgReduxService } from "./service/reduxstore/msg/msg.service";
import { HttpService } from "./service/auth/http/http.service";
import { httpFactory } from "./service/auth/http/http.factory";
import { ClientSocketService } from "./service/websockettest/client.socket";
import { httpFactorys, HttpXHRBackendService } from "./service/auth/interceptor/http.xhrbackend.service";
import { HttpInterceptorService } from "./service/auth/interceptor/http.interceptor.service";

@NgModule({
    declarations: [MainComponent, LayerComponent],
    exports: [CoreRoutingModule],
    imports: [CommonModule, CoreRoutingModule, HttpModule, StoreModule.forRoot({
        msg: MsgTable
    })],
    providers: [
        {
            provide: 'pconfig', useValue: new PublicConfig()
        }, {
            provide: TabService,
            useClass: TabService
        }, {
            provide: FormService,
            useFactory: (http: Http, pconfig: PublicConfig) => {
                return new FormService(http, pconfig);
            },
            deps: [Http, 'pconfig']
        }, {
            provide: RegisterService,
            useClass: RegisterService
        },
        {
            provide: PropupMsgReduxService,
            useClass: PropupMsgReduxService
        }, {
            provide: HttpService,
            useFactory: httpFactory,
            deps: [XHRBackend, RequestOptions]
        }, {
            provide: ClientSocketService,
            useClass: ClientSocketService
        },{
            provide:Http,
            useFactory:httpFactorys,
            deps:[
                HttpXHRBackendService,
                RequestOptions
            ]
        }
        ,HttpXHRBackendService,
        HttpInterceptorService
    ]
})
export class CoreModule {

}